package com.example.job_backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.job_backend.mapper.NoticeMapper;
import com.example.job_backend.model.Notice;
import com.example.job_backend.model.Query.NotificationQuery;
import com.example.job_backend.service.NotificationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NotificationServiceimpl extends ServiceImpl<NoticeMapper, Notice> implements NotificationService {
    @Resource
    private NoticeMapper noticeMapper;
//    @Override
//    public List<Notice> searchNotice(String title, String status) {
//        QueryWrapper<Notice> wrapper =new QueryWrapper<>();
//        wrapper.like("title",title)
//                .like("status",status);
//        return noticeMapper.selectList(wrapper);
//    }

    @Override
    public PageInfo<Notice> getNoticeByPage(NotificationQuery query) {
        PageHelper.startPage(query.getPage(), query.getPageSize());
        QueryWrapper<Notice> wrapper = new QueryWrapper<>();
        wrapper.like("title", query.getTitle())
                .like("status", query.getStatus());
        List<Notice> list = baseMapper.selectList(wrapper);
        PageInfo<Notice> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
